package com.mobi.Survey.map;

import android.view.View;
import android.view.Window;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.widget.ProgressBar;

import com.mobi.Survey.lib.activities.AbstractScreen;

public class ContainerWeb extends Container {

	private WebView wv;
	private AbstractScreen parent;
	private ProgressBar pb;

	public ContainerWeb(AbstractScreen v) {
		this.parent = v;
	}

	public void unload() {
		wv.loadUrl("about:blank");
	}

	@Override
	public void setupViews() {
		container = this.parent.findViewById(R.id.containerWeb);
		pb = (ProgressBar) this.parent.findViewById(R.id.pbWebview);
		wv = (WebView) parent.findViewById(R.id.webView);
		wv.setWebChromeClient(new WebChromeClient() {
			public void onProgressChanged(WebView view, int progress) {
				pb.setProgress(progress);
				if (progress == 100) {
					pb.setVisibility(View.GONE);
				}
			}
		});

	}

	public void open(String url) {
		pb.setProgress(0);
		pb.setVisibility(View.VISIBLE);
		wv.getSettings().setLoadsImagesAutomatically(true);
		wv.getSettings().setJavaScriptEnabled(true);
		wv.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
		wv.loadUrl(url);

	}

	@Override
	public void refresh() {

	}

}
